package com.hgkj.cloud.base.scheme.table;

import com.hgkj.cloud.base.scheme.ClsAnswerRequest;
import com.hgkj.cloud.base.scheme.ClsAnswerResult;
import com.hgkj.cloud.base.scheme.ClsScore;

import java.util.Map;

/**
 *一百二十八、R.C检测表（Rc）共100题
 */
public class Table128 extends AbstractTable implements TableCalculate{
    String code = "";

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public ClsAnswerResult calc(ClsAnswerRequest answer) {
        return null;
    }

    @Override
    public String[] report(Map map) {
        return null;
    }
    
	private static ClsAnswerResult GetRcFactorScore(ClsAnswerRequest answer) {
		// 法制观念，道德水平，心理健康状况，就业能力，文化素质
		ClsAnswerResult result = new ClsAnswerResult();
		result.setMessage("");
		result.setType(answer.getType());
		result.setUuid(answer.getUuid());
		try {
			// 1正确题数
			int MAX_NUM = 100;

			int intI;
			String[] strAnswer_c = answer.getAnswer().split(g_sChar);
			if (strAnswer_c.length > 1) {
				for (intI = 1; intI < strAnswer_c.length; intI++) {
					strAnswer_c[intI] = strAnswer_c[intI].trim();
				}
			}

			String[] strClientAnswerA = strAnswer_c[0].toString().split(g_nChar);

			if (strClientAnswerA.length != MAX_NUM) {
				result.setMessage("答案数量不符！");
				return result;
			}

			int i, j;

			// 共6组，第一组0,1,2；第二组0,2,1；第三组1,0,2；第四组1,2,0；第五组2,0,1；第六组2,1,0
			int[][] intScoreA = { { 0, 1, 2 }, { 0, 2, 1 }, { 1, 0, 2 }, { 1, 2, 0 }, { 2, 0, 1 }, { 2, 1, 0 } };
			int[] intSection = { 30, 55, 75, 90, 100 };

			String[] vDoctorIdeaA = new String[5];
			float[] vFactorA = new float[5];
			for (i = 0; i < vFactorA.length; i++) {
				vFactorA[i] = 0;
				vDoctorIdeaA[i] = "";
			}

			int idx = 0;
			int scr = 0;

			// 原始代码
			// For i = 0 To strClientAnswerA.Length - 1
			for (i = 0; i < strClientAnswerA.length; i++) {
				switch (i + 1) // 题目
				{
				case 30:
				case 68:
				case 89:
				case 95:
					scr = 0;
					break;
				case 1:
				case 9:
				case 46:
				case 56:
				case 71:
				case 85:
					scr = 1;
					break;
				case 29:
				case 41:
				case 47:
				case 78:
					scr = 2;
					break;
				case 2:
				case 13:
				case 34:
				case 37:
				case 58:
				case 67:
				case 92:
					scr = 3;
					break;
				case 5:
				case 6:
				case 35:
					scr = 4;
					break;
				default:
					scr = 5;
				}

				if (i >= intSection[idx]) {
					idx += 1;
				}
				vFactorA[idx] += intScoreA[scr][Integer.valueOf(strClientAnswerA[i]) - 1];
			}

			// 按原始分得到“医生意见”
			int[][] intValueA = { { 48, 36 }, { 40, 30 }, { 32, 24 }, { 24, 18 }, { 16, 12 } };
			for (i = 0; i < vFactorA.length; i++) {
				vDoctorIdeaA[i] = "Rc." + String.valueOf(i + 1) + ".3";
				for (j = 0; j < intValueA[0].length; j++) {
					if (vFactorA[i] >= intValueA[i][j]) {
						vDoctorIdeaA[i] = "Rc." + String.valueOf(i + 1) + "." + String.valueOf(j + 1);
						break;
					}
				}
			}

			ClsScore.Rc rc = new ClsScore.Rc();

			rc.setFzgn_o(vFactorA[0]);
			rc.setFzgn_d(vDoctorIdeaA[0]);

			rc.setDdsp_o(vFactorA[1]);
			rc.setDdsp_d(vDoctorIdeaA[1]);

			rc.setXljk_o(vFactorA[2]);
			rc.setXljk_d(vDoctorIdeaA[2]);

			rc.setJynl_o(vFactorA[3]);
			rc.setJynl_d(vDoctorIdeaA[3]);

			rc.setWhsz_o(vFactorA[4]);
			rc.setWhsz_d(vDoctorIdeaA[4]);

			result.setObject(rc);
			return result;
		} catch (ArithmeticException e) {
			result.setMessage(e.toString());
			return result;
		}
	}

}
